#include<stdio.h>
void move(int n,char A,char B,char C)
{
	if(n==1)
	{
		printf("move %d from A to C\n",n);
	}
	else
	{
		move(n-1,A,C,B);
		printf("move %d from A to C\n",n);
		move(n-1,B,A,C);
	}
}
int main()
{
	int n;
	char A='A',B='B',C='C';
	while(~(scanf("%d",&n)))//while(scanf("%d",&n)!=EOF)
	{
		move(n,A,B,C);
	}
	return 0;
}
